import java.math.BigInteger;
import java.util.Scanner;
public class TLE {
  static final BigInteger MOD = new BigInteger("1000000007");
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int tc = input.nextInt();
    while(tc--!=0) {
      BigInteger a = new BigInteger(input.next());
      BigInteger b = new BigInteger(input.next());
      BigInteger c = new BigInteger(input.next());
      System.out.println(a.modPow(b.modPow(c, MOD-1), MOD));
    }
  }
}
